package www.openteam.com.presenter;

import java.util.HashMap;

import www.openteam.com.base.BasePresenter;
import www.openteam.com.bean.AppAuthority;
import www.openteam.com.contract.FAuthorityContract;
import www.openteam.com.model.FAuthorityModel;
import www.openteam.com.mvp.IModel;
import www.openteam.com.ui.HomeFragmet;

/**
 * Created by kylin on 2017/3/21.
 */

public class FAuthorityPresenter
        extends BasePresenter<HomeFragmet> implements FAuthorityContract.FAuthorityPresenter{
    @Override
    public HashMap<String, IModel> getiModelMap() {
        return loadModelMap(new FAuthorityModel());
    }

    @Override
    public HashMap<String, IModel> loadModelMap(IModel... models) {
         HashMap<String,IModel>  hashMap = new HashMap<>();
        hashMap.put("FAuthority",models[0]);

        return hashMap;
    }

    @Override
    public void checkAuthority(String aCode, int uId) {
        ((FAuthorityModel)getiModelMap().get("FAuthority"))
                .checkAuthority(aCode, uId, new FAuthorityModel.FAuthorityOnListener() {
                    @Override
                    public void successInfo(AppAuthority appAuthority) {

                            getIView().FAuthoritySuccess(appAuthority);

                    }

                    @Override
                    public void failInfo(String str) {
                            getIView().FAuthorityFail(str);
                    }
                });

    }
}
